package com.gxa.controller.lgr.appointment;

import com.gxa.common.R;
import com.gxa.common.vo.AppointmentPageRequest;
import com.gxa.common.vo.AppointmentSettingVo;
import com.gxa.service.AppointmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author MacieSerenity
 */
@Controller
@RequestMapping("/appointment/setting")
@RequiresRoles(value = {"超级管理员","院长","主任","秘书","助理"},logical = Logical.OR)
@Api(value = "预约设置", tags = "预约设置数据接口")
public class AppointmentSettingController {

    @Autowired
    AppointmentService appointmentService;

    /**
     * 分页查询预约设置信息
     *
     * @param appointmentPageRequest 封装的带有pageNum pageSize 和查询条件query的实体
     * @return R
     */
    @ApiOperation(value = "根据分页查询获取预约设置信息", httpMethod = "POST", notes = "返回固定数量的分页数据", response = R.class)
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 404, message = "找不到页面"), @ApiResponse(code = 500, message = "后台服务错误")})
    @PostMapping("/findAppointmentUserList")
    @ResponseBody
    public R findAppointmentUserList(@RequestBody(required = false) AppointmentPageRequest appointmentPageRequest) {
        return appointmentService.findAppointmentUserList(appointmentPageRequest);
    }


    /**
     * 根据查询条件进行查询列表
     *
     * @param appointmentPageRequest 封装的带有pageNum pageSize 和查询条件query的实体
     * @return R
     */
    @ApiOperation(value = "根据传输的条件分页查询获取预约设置信息", httpMethod = "POST", notes = "返回固定数量的分页数据", response = R.class)
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 404, message = "找不到页面"), @ApiResponse(code = 500, message = "后台服务错误")})
    @PostMapping("/queryAppointmentUserList")
    @ResponseBody
    public R queryAppointmentUserList(@RequestBody(required = false) AppointmentPageRequest appointmentPageRequest) {
        return appointmentService.findAppointmentUserList(appointmentPageRequest);
    }

    /**
     * 添加一条预约设置信息
     *
     * @param appointmentSetting 预约设置信息的实体
     * @return R
     */
    @ApiOperation(value = "添加一条可预约人", httpMethod = "POST", notes = "返回固定数量的分页数据", response = R.class)
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 404, message = "找不到页面"), @ApiResponse(code = 500, message = "后台服务错误")})
    @PostMapping("/addAppointmentUser")
    @ResponseBody
    public R addAppointmentUser(@RequestBody AppointmentSettingVo appointmentSetting) {
        return appointmentService.addAppointmentUser(appointmentSetting);
    }

    /**
     * 更新一条预约设置信息
     *
     * @param appointmentSetting 预约设置信息的实体
     * @return R
     */
    @ApiOperation(value = "更新一条预约设置信息", httpMethod = "POST", notes = "返回固定数量的分页数据", response = R.class)
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 404, message = "找不到页面"), @ApiResponse(code = 500, message = "后台服务错误")})
    @PostMapping("/updateAppointmentUser")
    @ResponseBody
    public R updateAppointmentUser(@RequestBody AppointmentSettingVo appointmentSetting) {
        return appointmentService.updateAppointmentUser(appointmentSetting);
    }

    /**
     * 根据ID删除一条预约信息
     *
     * @param id 预约信息的id
     * @return R
     */
    @ApiOperation(value = "根据ID删除某一条预约信息", httpMethod = "POST", notes = "返回固定数量的分页数据", response = R.class)
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 404, message = "找不到页面"), @ApiResponse(code = 500, message = "后台服务错误")})
    @PostMapping("/deleteAppointmentUser")
    @ResponseBody
    public R deleteAppointmentUser(@RequestParam("id") Integer id) {
        return appointmentService.deleteAppointmentSettingById(id);
    }

}
